home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-14 | 5.5 KB | 162 lines | [TEXT/MPS ] |
- /* _________________________________________________________________________________________________________ //
- Copyright © 1992-93 Apple Computer, Inc. All rights reserved.
- Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
- Programmer: Kent Sandvik
- Date: 12/27/92
- Revision comments are at the end of this file.
- ---
- TFile is a simple object that does file manipulations
- TFile.h contains the TFile class and subclass definitions.
- _________________________________________________________________________________________________________ */
-
- // Declare label for this header file
- #ifndef _FILECLASS_
- #define _FILECLASS_
-
- #ifndef _DTSCPLUSLIBRARY_
- #include "DTSCPlusLibrary.h"
- #endif
-
- #ifndef __FILES__
- #include <Files.h>
- #endif
-
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- // globals
- const OSType kDefaultCreator = '????';
- const OSType kDefaultType = 'TEXT';
- const SignedByte kExclusiveReadWrite = 0;
- const long kNoOffset = 0L;
-
- // _________________________________________________________________________________________________________ //
- // TFile Class Interface.
- class TFile
- // Basic File class for file I/O handling.
- {
- public:
- // CONSTRUCTORS AND DESTRUCTORS
- TFile(char* name = "UnTitled"); // define file based on name (current folder)
- TFile(FSSpec theSpec); // define file based on FSSpec
- TFile(short volume, // define file based on volume, dirID and name (FSSpec)
- long dirID,
- Str63 name);
-
- virtual~ TFile(); // default destructor
-
- virtual void Initialize(); // initialize fields to known values
-
- // MAIN INTERFACE
- virtual Boolean Create(); // create a file
- virtual Boolean Rename(char* newName); // rename the file
- virtual void Delete(); // delete the file
- virtual Boolean FileExists(); // check if file exists
- virtual Boolean Open(SignedByte permission) = 0;// open file
- virtual Boolean Close() = 0; // close file
-
- // ACCESSORS AND MUTATORS
- virtual void SetType(const OSType creator, // define file type and creator
- const OSType fileType);
- virtual void SetFileName(const Str63 fileName); // set name of file
- virtual FInfo GetFileInfo(); // get file information frome the specific file
-
- // FIELDS
- protected:
- FSSpec fFileSpec; // the generic container for File information
- OSType fFileType; // type of file
- OSType fCreator; // creator of file
- Boolean fOpened; // keep track if the file is open or not
- Boolean fFlushing; // should we flush after each file operation?
- short fRefNum; // reference number to the file
- OSErr fError; // latest error
- };
-
-
- // _________________________________________________________________________________________________________ //
- // TDataFile Class Interface.
- class TDataFile : public TFile
- // TData file is a file that uses mainly the data fork of the file.
- {
- public:
- // CONSTRUCTORS AND DESTRUCTORS
- TDataFile(char* name = "UnTitled"); // default constructor
- ~TDataFile(); // default destructor
-
- // MAIN INTERFACE
- virtual Boolean Open(SignedByte permission = kExclusiveReadWrite);// exclusive read/write permission
- virtual Boolean Close(); // close the file
- virtual Boolean WriteHandle(Handle h); // write handle into disk
- virtual Handle ReadHandle(); // read handle from disk
- virtual Boolean Write(Ptr buffer,
- long bytes); // write bytes to disk from current mark
- virtual Boolean Read(Ptr buffer,
- long bytes); // read bytes from disk at current mark
- virtual Boolean SetMark(short from,
- long offset); // set offset of mark
- virtual long GetMark(); // get offset
- virtual Boolean Reset(); // set file mark to beginning of file
- virtual Boolean GotoEndOfFile(); // set file mark at end of file
- };
-
- // _________________________________________________________________________________________________________ //
- // TResourceFile Class Interface.
- class TResourceFile : public TFile
- // TResourceFile uses mainly the resource fork of the file.
- {
- public:
- // CONSTRUCTORS AND DESTRUCTORS
- TResourceFile(char* name = "UnTitled"); // default constructor
- ~TResourceFile(); // default destructor
-
- // MAIN INTERFACE
- virtual Boolean Create(); // create a file
- virtual Boolean Open(SignedByte permission = kExclusiveReadWrite); // open the file
- virtual Boolean Close(); // close the file
-
- virtual Boolean HasResourceFork(); // test if file has resource fork or not
- virtual void Update(); // update the file
- virtual void Assign(); // assign the file to the first one in the resource chain
- };
-
-
- // _________________________________________________________________________________________________________ //
- // MPreferences Class Interface.
- class MPreferences
- // Find and create files in the preferences section of the hard disk (future)
- {
- public:
- };
-
-
- // _________________________________________________________________________________________________________ //
- // MTempFile Class Interface.
- class MTempFile
- // Find and create files in the temp section of the hard disk (future)
- {
- public:
- };
-
-
- // _________________________________________________________________________________________________________ //
- // TLogFile Class Interface. (future)
- class TLogFile : public TFile
- {
- public:
- };
-
-
- #endif
-
- // _________________________________________________________________________________________________________ //
- /* Change History (most recent last):
- No Init. Date Comment
- 1 khs 12/27/92 New file
- 2 khs 1/14/93 Cleanup
- */
-